package controller.cartp;

import com.alibaba.fastjson.JSON;
import com.zuche.framework.tradingPlatform.CurrenceSource;
import com.zuche.framework.tradingPlatform.GroupType;
import com.zuche.framework.tradingPlatform.RequestParams;
import com.zuche.framework.utils.PropertiesReader;
import controller.constant.CarTpConstant;
import controller.remote.CartpRemoteClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by 雷霆 on 2016/10/25.
 */
@Controller
@RequestMapping(value = "icbc/",produces = "text/html;charset=utf-8")
public class ICBCELinkController {
    private String projectAddress;
    private static final Logger logger = LoggerFactory.getLogger(UnionPayRPCTestController.class);

    public ICBCELinkController() {
        this.projectAddress = PropertiesReader.getAppointPropertiesAttribute(
                "setting", "projectAddress", String.class);
    }


    @RequestMapping(value = "doicbcELinkPayInit.do_")
    public static  Object doicbcELinkPayInit(){
        Map<String,String> requestMap=new HashMap<String, String>();
        requestMap.put(RequestParams.SYS_GROUP, CarTpConstant.SYS_GROUP_UCAR);
        requestMap.put(RequestParams.GROUP_TYPE,"icbcELinkPayInit");
        requestMap.put(RequestParams.BUSINESS_NAME,"ICBCPay");
        requestMap.put("tp_client_url", "http://paytest.10101111.com/ThirdPartySimulatorProjDemo/pages/ticket/clientTicketForReal.html");

        logger.error(" [carttp调用参数] : " + JSON.toJSONString(requestMap));
        Map<String,String> resultMap = CartpRemoteClient.doRpcInvoke(requestMap, true);
        logger.error(" [carttp返回结果] : " + JSON.toJSONString(resultMap));

        return resultMap;
    }

    @RequestMapping(value = "doicbcELinkWapPay.do_")
    public static  Object doicbcELinkWapPay(){
        Map<String,String> requestMap=new HashMap<String, String>();
        requestMap.put(RequestParams.SYS_GROUP, CarTpConstant.SYS_GROUP_UCAR);
        requestMap.put(RequestParams.GROUP_TYPE,"icbcELinkWapPay");
        requestMap.put(RequestParams.GROUP_TYPE,"icbcELinkWapPay");
        requestMap.put(RequestParams.BUSINESS_NAME,"ICBCPay");
        requestMap.put(RequestParams.BUSINESS_ID,"DJP2257575203316");
        requestMap.put(RequestParams.RECORD_ID,"11130611436105612");
        requestMap.put(RequestParams.BUSINESS_MONEY, "1.0");
        requestMap.put("tp_client_url", "http://paytest03.10101111.com:9080/ThirdPartySimulatorProjDemo/pages/ticket/clientTicketForReal.html");

        logger.error(" [carttp调用参数] : " + JSON.toJSONString(requestMap));
        Map<String,String> resultMap = CartpRemoteClient.doRpcInvoke(requestMap, true);
        logger.error(" [carttp返回结果] : " + JSON.toJSONString(resultMap));

        return resultMap;
    }

    @RequestMapping(value = "icbcELinkAPPPay.do_")
    public static  Object doicbcELinkAPPPay(){
        Map<String,String> requestMap=new HashMap<String, String>();
        requestMap.put(RequestParams.SYS_GROUP, CarTpConstant.SYS_GROUP_UCAR);
        requestMap.put(RequestParams.GROUP_TYPE,"icbcELinkAPPPay");
        requestMap.put(RequestParams.BUSINESS_NAME,"ICBCPay");
        requestMap.put(RequestParams.BUSINESS_ID,"DJP2257575203316");
        requestMap.put(RequestParams.RECORD_ID,"11130611436105612");
        requestMap.put(RequestParams.BUSINESS_MONEY, "1.0");
        requestMap.put("tp_client_url", "https://detail.tmall.com/item.htm?spm=a220o.1000855.w4004-14831640363.2.oxhgFX&abtest=_AB-LR129-PR129&pvid=2dde790e-a7b9-47e6-91b5-88ba04275e0d&pos=1&abbucket=_AB-M129_B3&acm=03130.1003.1.701602&id=537619422734&scm=1007.12929.25829.100200300000000#fewe");
        logger.error(" [carttp调用参数] : " + JSON.toJSONString(requestMap));
          Map<String,String> resultMap = CartpRemoteClient.doRpcInvoke(requestMap, true);
        logger.error(" [carttp返回结果] : " + JSON.toJSONString(resultMap));

        return resultMap;
    }

    @RequestMapping(value = "doicbcELinkQueryOrder.do_")
    public static  Object doicbcELinkQueryOrder(){
        Map<String,String> requestMap=new HashMap<String, String>();
        requestMap.put(RequestParams.SYS_GROUP, CarTpConstant.SYS_GROUP_UCAR);
        requestMap.put(RequestParams.GROUP_TYPE,"icbcELinkQueryOrder");
        requestMap.put(RequestParams.BUSINESS_NAME,"ICBCPay");
        requestMap.put(RequestParams.RECORD_ID,"01130601522373530");
        logger.error(" [carttp调用参数] : " + JSON.toJSONString(requestMap));
        Map<String,String> resultMap = CartpRemoteClient.doRpcInvoke(requestMap, true);
            logger.error(" [carttp返回结果] : " + JSON.toJSONString(resultMap));

        return resultMap;
    }


    @RequestMapping(value = "doicbcELinkReverse.do_")
     public static  Object doicbcELinkReverse(){
        Map<String,String> requestMap=new HashMap<String, String>();
        requestMap.put(RequestParams.SYS_GROUP, CarTpConstant.SYS_GROUP_UCAR);
        requestMap.put(RequestParams.GROUP_TYPE,"icbcELinkReverse");
        requestMap.put(RequestParams.BUSINESS_NAME,"ICBCPay");
        requestMap.put(RequestParams.RECORD_ID,"03130601570506040");
        logger.error(" [carttp调用参数] : " + JSON.toJSONString(requestMap));
        Map<String,String> resultMap = CartpRemoteClient.doRpcInvoke(requestMap, true);
        logger.error(" [carttp返回结果] : " + JSON.toJSONString(resultMap));

        return resultMap;
    }

    @RequestMapping(value = "doicbcELinkRefund.do_")
    public static  Object doicbcELinkRefund(){
        Map<String,String> requestMap=new HashMap<String, String>();
        requestMap.put(RequestParams.SYS_GROUP, CarTpConstant.SYS_GROUP_UCAR);
        requestMap.put(RequestParams.GROUP_TYPE,"icbcELinkRefund");
        requestMap.put(RequestParams.BUSINESS_NAME,"ICBCPay");
        requestMap.put(RequestParams.RECORD_ID,"01130601522373530");
        logger.error(" [carttp调用参数] : " + JSON.toJSONString(requestMap));
        Map<String,String> resultMap = CartpRemoteClient.doRpcInvoke(requestMap, true);
        logger.error(" [carttp返回结果] : " + JSON.toJSONString(resultMap));

        return resultMap;
    }

    @RequestMapping(value = "doicbcELinkCreateMenu.do_")
    public static  Object doicbcELinkCreateMenu(){
        Map<String,String> requestMap=new HashMap<String, String>();
        requestMap.put(RequestParams.SYS_GROUP, CarTpConstant.SYS_GROUP_UCAR);
        requestMap.put(RequestParams.GROUP_TYPE,"icbcELinkCreateMenu");
        requestMap.put(RequestParams.BUSINESS_NAME,"ICBCPay");
        requestMap.put("tp_button_name","测试按钮2");
        requestMap.put("tp_button_type","viewurl");
        requestMap.put("tp_button_url","http://paytest.10101111.com");
        requestMap.put("tp_client_url", "https://detail.tmall.com/item.htm?spm=a220o.1000855.w4004-14831640363.2.oxhgFX&abtest=_AB-LR129-PR129&pvid=2dde790e-a7b9-47e6-91b5-88ba04275e0d&pos=1&abbucket=_AB-M129_B3&acm=03130.1003.1.701602&id=537619422734&scm=1007.12929.25829.100200300000000#fewe");
        logger.error(" [carttp调用参数] : " + JSON.toJSONString(requestMap));
        Map<String,String> resultMap = CartpRemoteClient.doRpcInvoke(requestMap, true);
        logger.error(" [carttp返回结果] : " + JSON.toJSONString(resultMap));

        return resultMap;
    }

    @RequestMapping(value = "doicbcELinkQueryMenu.do_")
      public static  Object doicbcELinkQueryMenu(){
        Map<String,String> requestMap=new HashMap<String, String>();
        requestMap.put(RequestParams.SYS_GROUP, CarTpConstant.SYS_GROUP_UCAR);
        requestMap.put(RequestParams.GROUP_TYPE,"icbcELinkQueryMenu");
        requestMap.put(RequestParams.BUSINESS_NAME,"ICBCPay");
        logger.error(" [carttp调用参数] : " + JSON.toJSONString(requestMap));
        Map<String,String> resultMap = CartpRemoteClient.doRpcInvoke(requestMap, true);
        logger.error(" [carttp返回结果] : " + JSON.toJSONString(resultMap));

        return resultMap;
    }
    @RequestMapping(value = "doicbcELinkDeleteMenu.do_")
    public static  Object doicbcELinkDeleteMenu(){
        Map<String,String> requestMap=new HashMap<String, String>();
        requestMap.put(RequestParams.SYS_GROUP, CarTpConstant.SYS_GROUP_UCAR);
        requestMap.put(RequestParams.GROUP_TYPE,"icbcELinkDeleteMenu");
        requestMap.put(RequestParams.BUSINESS_NAME,"ICBCPay");
        logger.error(" [carttp调用参数] : " + JSON.toJSONString(requestMap));
        Map<String,String> resultMap = CartpRemoteClient.doRpcInvoke(requestMap, true);
        logger.error(" [carttp返回结果] : " + JSON.toJSONString(resultMap));

        return resultMap;
    }


}
